Class PacketTracerReadWorkerImpl

java.lang.Object
java.lang.Thread
com.cisco.pt.ptmp.impl.PacketTracerReadWorkerImpl
All Implemented Interfaces:
PacketTracerReadWorker, Runnable

public class PacketTracerReadWorkerImpl extends Thread implements PacketTracerReadWorker
Provides a thread to read response messages and asynchronous (out-of-band) event messages sent by Packet Tracer.
Author:
packettracerexapps@external.cisco.com
  • Field Details

  • Constructor Details

    • PacketTracerReadWorkerImpl

      public PacketTracerReadWorkerImpl(PacketTracerSession session, Pipeline pipeline)
      Create a new PacketTracerReadWorkerImpl that will use the given Pipeline for reading messages from Packet Tracer.
      Parameters:
      session - The PacketTracerSession that created this object. Events received from Packet Tracer will be returned to the session for further processing.
      pipeline - The read pipeline to use
  • Method Details

    • getPipeline

      public Pipeline getPipeline()
      Description copied from interface: PacketTracerReadWorker
      Returns the pipeline used for reading
      Specified by:
      getPipeline in interface PacketTracerReadWorker
      Returns:
      The underlying pipeline
    • registerRequest

      public void registerRequest(LTV ltv)
      Description copied from interface: PacketTracerReadWorker
      Creates an entry that will be matched with any response to the ltv from Packet Tracer
      Specified by:
      registerRequest in interface PacketTracerReadWorker
      Parameters:
      ltv - A message being sent that will generate a response from Packet Tracer
    • getResponse

      public LTV getResponse(LTV ltv)
      Description copied from interface: PacketTracerReadWorker
      Blocks the current Thread until a response message for ltv is received from Packet Tracer
      Specified by:
      getResponse in interface PacketTracerReadWorker
      Parameters:
      ltv - The message whose response is desired
      Returns:
      the response LTV received from Packet Tracer
    • shouldStop

      public void shouldStop()
      Description copied from interface: PacketTracerReadWorker
      Causes this worker to stop running. This may take effect immediately, or after an unspecified delay.
      Specified by:
      shouldStop in interface PacketTracerReadWorker
    • run

      public void run()
      This is the body of the Thread, in which this object does its work. It continually reads messages on the pipeline from Packet Tracer. If they're responses, it attempts to match the response (by message ID) with the request that generated it. It they're events, it forwards them to the event handler for additional processing. If they're neither responses nor events, or if they're responses with no request waiting on them, they're discarded with logging.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • discardUnmatchedResponse

      protected void discardUnmatchedResponse(LTV ltv)
      Note a response message that had no matching requester. This is a hook for logging, as this is not necessarily an error condition ... it may be that another object wanted to send an IPC message and had no interest in what if any response came back.
      Parameters:
      ltv - The response message
    • discardUnknownMessage

      protected void discardUnknownMessage(LTV ltv)
      Note a read message that's neither a response nor an event. This is a hook for logging, as this is not necessarily an error condition.
      Parameters:
      ltv - The unrecognized message
    • readKeepAlive

      protected void readKeepAlive(LTV ltv)